﻿using System.Collections.ObjectModel;
using Ninject.Core.Parameters;
using TestBat.IModels.Domain;
using TestBat.IModels.Models;
using TestBat.IViewModels.Base;
using TestBat.IViewModels.Workspaces.Tasks;
using TestBat.ServiceLocator;

namespace TestBat.ViewModels.Workspaces.Tasks
{
    public class ChoiceListViewModel : ListViewModel<IChoiceViewModel, ObservableCollection<IChoiceViewModel>>, IChoiceListViewModel
    {
        public ChoiceListViewModel(IChoiceTask task, ITaskModel taskModel)
            : base(false)
        {
            this.task = task;
            this.taskModel = taskModel;
        }

        protected override ObservableCollection<IChoiceViewModel> _RecreateItems()
        {
            ObservableCollection<IChoiceViewModel> list = new ObservableCollection<IChoiceViewModel>();

            foreach (var c in taskModel.GetChoices(task))
            {
                IChoiceViewModel viewModel = DefaultServiceLocator.Get<IChoiceViewModel>(With.Parameters.ConstructorArgument("choice", c));
                list.Add(viewModel);
            }

            return list;
        }

        private readonly IChoiceTask task;
        private readonly ITaskModel taskModel;
    }
}
